#!/usr/bin/python

from google.appengine.api import memcache

from DataStore import DataStore

class MemCache:

	BLOG_INFO_KEY = 'BLOG_INFO'

	@classmethod
	def get_blog_info(cls):
		ret = memcache.get(cls.BLOG_INFO_KEY)
		if ret is not None:
			return ret
		else:
			blog = DataStore.get_blog_info()
			memcache.add(cls.BLOG_INFO_KEY, blog)
			return blog

    @classmethod
    def get_post_by_id(cls, pid):
        key = cls.POST_KEY + str(pid)
        ret = memcache.get(key)
        if ret is not None:
            return ret
        else:
            post = DataStore.get_post_by_id(pid)
            memcache.add(key, post)
            return post
